﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;

namespace HelpDesk
{
    public partial class VerEstadisticas : System.Web.UI.Page
    {

        QueryBuilder Consulta = new QueryBuilder();
        Estadisticas Reporte = new Estadisticas();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string sql = "";
                bool exitoso = false;
                string x = ListBox1.SelectedItem.Value;
                string y = ListBox3.SelectedItem.Value;
                string fi = Calendar1.SelectedDate.ToString("dd/mm/yyyy").Substring(0, 10);
                string ff = Calendar2.SelectedDate.ToString("dd/mm/yyyy").Substring(0, 10);
                DataTable datos = new DataTable();
                switch (x)
                {
                    #region AREA
                    case ("Areas"):
                        if (SelTodo1.Checked == false)
                        {
                            //uno X
                            if (SelTodo2.Checked == false)
                            {
                                //uno X, uno Y
                                if (y.Equals("Infraestructuras"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox2.SelectedItem.Value + "') and infraestructura= (select id_infraestructura from infraestructura where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Areas", "");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox2.SelectedItem.Value + "') and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Areas", "");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox2.SelectedItem.Value + "') and problema= (select id_problema from problema where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Areas", "");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //uno X, muchos Y
                                if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Problemas");
                                }
                            }
                            if (exitoso == true)
                                Label_Error.Text = "Reporte Creado Exitosamente";
                            else
                                Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                        }
                        else
                        {
                            //muchos en X
                            if (SelTodo2.Checked == false)
                            {
                                //uno en Y
                                if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //muchos en X, muchos en Y
                                if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Areas", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        break;
                    #endregion

                    #region Infraestructuras
                    case ("Infraestructuras"):

                        if (SelTodo1.Checked == false)
                        {
                            //uno X
                            if (SelTodo2.Checked == false)
                            {
                                //uno X, uno Y
                                if (y.Equals("Areas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Infraestructura= (select id_infraestructura from Infraestructura where descripcion='" + ListBox2.SelectedItem.Value + "') and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Infraestructura= (select id_infraestructura from Infraestructura where descripcion='" + ListBox2.SelectedItem.Value + "') and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Infraestructura= (select id_infraestructura from Infraestructura where descripcion='" + ListBox2.SelectedItem.Value + "') and problema= (select id_problema from problema where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //uno X, muchos Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Areas");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        else
                        {
                            //muchos en X
                            if (SelTodo2.Checked == false)
                            {
                                //uno en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Areas");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //muchos en X, muchos en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Areas");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Usuarios");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Infraestructuras", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        break;
                    #endregion

                    #region Usuarios
                    case ("Usuarios"):
                        if (SelTodo1.Checked == false)
                        {
                            //uno X
                            if (SelTodo2.Checked == false)
                            {
                                //uno X, uno Y
                                if (y.Equals("Areas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox2.SelectedItem.Value + "') and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox2.SelectedItem.Value + "') and infraestructura= (select id_infraestructura from infraestructura where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox2.SelectedItem.Value + "') and problema= (select id_problema from problema where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //uno X, muchos Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Infraestructuras");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        else
                        {
                            //muchos en X
                            if (SelTodo2.Checked == false)
                            {
                                //uno en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Infraestructuras");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //muchos en X, muchos en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Infraestructuras");
                                }
                                else if (y.Equals("Problemas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Usuarios", "Problemas");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        break;

                    #endregion

                    #region Problemas
                    case ("Problemas"):

                        if (SelTodo1.Checked == false)
                        {
                            //uno X
                            if (SelTodo2.Checked == false)
                            {
                                //uno X, uno Y
                                if (y.Equals("Areas"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Problema= (select id_problema from Problema where descripcion='" + ListBox2.SelectedItem.Value + "') and area_origen= (select id_area from Area_trabajo where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Problema= (select id_problema from Problema where descripcion='" + ListBox2.SelectedItem.Value + "') and infraestructura= (select id_infraestructura from infraestructura where descripcion='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    sql = "select count(id_ticket) from ticket where Fecha_inicio between '" + fi + "' and '" + ff + "' and Problema= (select id_problema from Problema where descripcion='" + ListBox2.SelectedItem.Value + "') and usuario_ticket= (select id_usuario from usuario where id_usuario='" + ListBox4.SelectedItem.Value + "')";
                                    exitoso = Reporte.Crear_Grafica(null, null, ListBox2.SelectedItem.Value, ListBox4.SelectedItem.Value, sql, fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //uno X, muchos Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(null, ListBox4, ListBox2.SelectedItem.Value, "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Usuarios");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        else
                        {
                            //muchos en X
                            if (SelTodo2.Checked == false)
                            {
                                //uno en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, null, "", ListBox4.SelectedItem.Value, "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Usuarios");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                            else
                            {
                                //muchos en X, muchos en Y
                                if (y.Equals("Areas"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Areas");
                                }
                                else if (y.Equals("Infraestructuras"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Infraestructuras");
                                }
                                else if (y.Equals("Usuarios"))
                                {
                                    exitoso = Reporte.Crear_Grafica(ListBox2, ListBox4, "", "", "", fi, ff, DropDownList1.SelectedItem.Value, "Problemas", "Usuarios");
                                }
                                if (exitoso == true)
                                    Label_Error.Text = "Reporte Creado Exitosamente";
                                else
                                    Label_Error.Text = "A Ocurrido un Error al Crear el Reporte";
                            }
                        }
                        break;
                        #endregion
                }

            }
            catch (Exception ex) { ex.ToString(); }
        }

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ListBox1.SelectedItem.Value == "Areas")
            {
                ListBox2.Items.Clear();
                ListBox2.DataSourceID = "SqlDSArea";
            }
            else if (ListBox1.SelectedItem.Value == "Infraestructuras")
            {
                ListBox2.Items.Clear();
                ListBox2.DataSourceID = "SqlDSInfraestructura";
            }
            else if (ListBox1.SelectedItem.Value == "Usuarios")
            {
                ListBox2.Items.Clear();
                ListBox2.DataSourceID = "SqlDSUsuario";
            }
            else if (ListBox1.SelectedItem.Value == "Problemas")
            {
                ListBox2.Items.Clear();
                ListBox2.DataSourceID = "SqlDSProblema";
            }
            else
            {
                ListBox2.Items.Clear();
                ListBox2.Items.Add("No debe seleccionar la misma opcion del Y");
            }
        }

        protected void ListBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ListBox3.SelectedItem.Value == "Areas" && ListBox1.SelectedItem.Value != "Areas")
            {
                ListBox4.Items.Clear();
                ListBox4.DataSourceID = "SqlDSArea";
            }
            else if (ListBox3.SelectedItem.Value == "Infraestructuras" && ListBox1.SelectedItem.Value != "Infraestructuras")
            {
                ListBox4.Items.Clear();
                ListBox4.DataSourceID = "SqlDSInfraestructura";
            }
            else if (ListBox3.SelectedItem.Value == "Usuarios" && ListBox1.SelectedItem.Value != "Usuarios")
            {
                ListBox4.Items.Clear();
                ListBox4.DataSourceID = "SqlDSUsuario";
            }
            else if (ListBox3.SelectedItem.Value == "Problemas" && ListBox1.SelectedItem.Value != "Problemas")
            {
                ListBox4.Items.Clear();
                ListBox4.DataSourceID = "SqlDSProblema";
            }
            else
            {
                ListBox4.Items.Clear();
                ListBox4.Items.Add("No debe seleccionar la misma opcion del X");
            }
        }
    }
}